{
 "cells": [
  {
   "cell_type": "code",
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2025-09-06T17:00:17.682506Z",
     "start_time": "2025-09-06T17:00:17.676476Z"
    }
   },
   "source": [
    "a = {\"name\": \"李华\", \"hobby_list\": [\"basketball\", \"football\", \"pingpong\"], \"info\": {\"address\": \"xxxxx\", \"phone\": \"111111\"}}\n",
    "a"
   ],
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'name': '李华',\n",
       " 'hobby_list': ['basketball', 'football', 'pingpong'],\n",
       " 'info': {'address': 'xxxxx', 'phone': '111111'}}"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 8
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-09-06T17:00:18.314812Z",
     "start_time": "2025-09-06T17:00:18.310657Z"
    }
   },
   "cell_type": "code",
   "source": [
    "from pprint import pprint\n",
    "pprint(a)"
   ],
   "id": "bc365fce472385a0",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'hobby_list': ['basketball', 'football', 'pingpong'],\n",
      " 'info': {'address': 'xxxxx', 'phone': '111111'},\n",
      " 'name': '李华'}\n"
     ]
    }
   ],
   "execution_count": 9
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-09-06T17:00:19.043553Z",
     "start_time": "2025-09-06T17:00:19.039080Z"
    }
   },
   "cell_type": "code",
   "source": [
    "import json\n",
    "\n",
    "print(json.dumps(a, indent=4, sort_keys=False, ensure_ascii=False))"
   ],
   "id": "5c8a32341ad67e7",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\n",
      "    \"name\": \"李华\",\n",
      "    \"hobby_list\": [\n",
      "        \"basketball\",\n",
      "        \"football\",\n",
      "        \"pingpong\"\n",
      "    ],\n",
      "    \"info\": {\n",
      "        \"address\": \"xxxxx\",\n",
      "        \"phone\": \"111111\"\n",
      "    }\n",
      "}\n"
     ]
    }
   ],
   "execution_count": 10
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-09-06T17:00:55.865393Z",
     "start_time": "2025-09-06T17:00:55.857295Z"
    }
   },
   "cell_type": "code",
   "source": [
    "import yaml\n",
    "\n",
    "print(yaml.dump(a, allow_unicode=True))"
   ],
   "id": "a1a6d6d5d4ea0f0f",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hobby_list:\n",
      "- basketball\n",
      "- football\n",
      "- pingpong\n",
      "info:\n",
      "  address: xxxxx\n",
      "  phone: '111111'\n",
      "name: 李华\n",
      "\n"
     ]
    }
   ],
   "execution_count": 12
  },
  {
   "metadata": {},
   "cell_type": "code",
   "outputs": [],
   "execution_count": null,
   "source": "",
   "id": "19771d2ea379f70b"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
